package com.jxw.launcher;

import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.util.AttributeSet;
import android.view.View;

/* loaded from: classes.dex */
public class BannerIndicator extends View {
    private int currentPosition;
    private int mCellCount;
    private int mCellMargin;
    private int mCellRadius;
    private int mIndicatorColor;
    private int mNoIndicatorColor;
    private Paint mPaint;

    public BannerIndicator(Context context) {
        this(context, null);
    }

    public BannerIndicator(Context context, AttributeSet attributeSet) {
        this(context, attributeSet, 0);
    }

    public BannerIndicator(Context context, AttributeSet attributeSet, int i) {
        super(context, attributeSet, i);
        this.mCellRadius = 4;
        this.mCellMargin = 15;
        this.mIndicatorColor = Color.parseColor("#FFFFFF");
        this.mNoIndicatorColor = Color.parseColor("#66FFFFFF");
        init();
    }

    public void init() {
        this.mPaint = new Paint();
        this.mPaint.setAntiAlias(true);
    }

    public void setCellCount(int i) {
        this.mCellCount = i;
        invalidate();
    }

    public void setCurrentPosition(int i) {
        this.currentPosition = i;
        invalidate();
    }

    @Override // android.view.View
    protected void onMeasure(int i, int i2) {
        super.onMeasure(i, i2);
        int i3 = this.mCellCount;
        setMeasuredDimension(resolveSize(getPaddingLeft() + getPaddingRight() + (this.mCellRadius * 2 * i3) + (this.mCellMargin * (i3 - 1)), i), resolveSize(getPaddingTop() + getPaddingBottom() + (this.mCellRadius * 2), i2));
    }

    @Override // android.view.View
    protected void onDraw(Canvas canvas) {
        super.onDraw(canvas);
        for (int i = 0; i < this.mCellCount; i++) {
            if (i == this.currentPosition) {
                this.mPaint.setColor(this.mIndicatorColor);
            } else {
                this.mPaint.setColor(this.mNoIndicatorColor);
            }
            int paddingLeft = getPaddingLeft();
            int i2 = this.mCellRadius;
            canvas.drawCircle(paddingLeft + (i * i2 * 2) + (this.mCellMargin * i) + i2, getHeight() / 2, this.mCellRadius, this.mPaint);
        }
    }
}
